package Template5::Info::Element::Info;

#public
sub new($$)
{
	my $class     = shift;
	my $hHTMLNode = shift;
	my $params    = shift;	
	my $this      = {'infotag' => $hHTMLNode,
									 'params'  => {}};

	return bless($this, $class);
};

#public
sub get_value($)
{
	my $this = shift;
	my $name = shift;
	
	if(exists($this->{'params'}->{$name}))
	{
		return $this->{'params'}->{$name}->get_value();
	};
	
	return undef;
};

#public
sub set_value($$)
{
	my $this      = shift;
	my $name      = shift;
	my $value_obj = shift;

	$this->{'params'}->{$name} = $value_obj;
};

#public
sub clone()
{
	my $this   = shift;
	my %params = %{$this->{'params'}};
	
	my $obj  =
	{
		'infotag' => $this->{'infotag'}->clone(),
		'params'  => \%params
	};

	return bless($obj, ref($this));
};

#public
sub delete()
{
	my $this = shift;
	$this->{'infotag'}->delete();
}; 

#public
sub getstruct()
{
	my $this = shift;

	my $infotag = $this->{'infotag'}->clone();
	$infotag->delete_content();

	my ($prefix, $name) = split(/\:/, $infotag->tag(), 2);
	$prefix = (defined($name)?($prefix.':'):'');

	foreach my $key(keys(%{$this->{'params'}}))
	{
		my $value    = $this->get_value($key);
		my $valuetag = HTML::Element->new("$prefix$key");

		$valuetag->push_content($value);
		$infotag->unshift_content("\n\t\t", $valuetag);
	};
	
	return $infotag;
}; 

1;

